package JavaSE;

import java.util.Random;

public class time_20250421_生成随机数练习 {
    public static void main(String[] args){
        Random random = new Random();
        //生成均匀分布的整数  56到109之间的整数
        int uniformInt = random.nextInt(54)+56;
        System.out.println(uniformInt);

        //生成均匀分布浮点型随机数
        double uniformDouble1 = random.nextDouble();//默认生成0.0-1.0之间的均匀分布的浮点数
        System.out.println(uniformDouble1);

        double min = 10.0;
        double max = 13.0;
        double range = 13.0-10.0;
        double uniformDouble2 = random.nextDouble()*range + min;//生成任意范围的均匀分布的浮点数
        System.out.println(uniformDouble2);

        //生成正态分布的浮点数
        double normalDouble = random.nextGaussian();//均值为0.0，标准差为1.0的正态分布的随机数
        System.out.println(normalDouble);
    }
}
